﻿using B.S.InOut.Domain;
using MediatR;
using System.Threading;
using System.Threading.Tasks;

// 创建产品的请求类
public class CreateProductRequest : IRequest<int>
{
    public ProductModel Product { get; set; }
}

// 创建产品请求的处理程序
public class CreateProductHandler : IRequestHandler<CreateProductRequest, int>
{
    private readonly IBaseRepository<ProductModel> _repository;

    public CreateProductHandler(IBaseRepository<ProductModel> repository)
    {
        _repository = repository;
    }

    // 处理创建产品请求
    public async Task<int> Handle(CreateProductRequest request, CancellationToken cancellationToken)
    {
        return await _repository.InsertAsync(request.Product);
    }
}